home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / PMTTUN (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  4.0 KB  |  111 lines

  1. package com.sun.java.swing.plaf.basic;
  2.  
  3. import com.sun.java.swing.DesktopManager;
  4. import com.sun.java.swing.JComponent;
  5. import com.sun.java.swing.JDesktopPane;
  6. import com.sun.java.swing.JLayeredPane;
  7. import com.sun.java.swing.SwingUtilities;
  8. import java.awt.Component;
  9. import java.awt.Insets;
  10. import java.awt.Point;
  11. import java.awt.Rectangle;
  12. import java.awt.event.MouseAdapter;
  13. import java.awt.event.MouseEvent;
  14. import java.awt.event.MouseMotionListener;
  15. import java.beans.PropertyVetoException;
  16. import java.io.Serializable;
  17. import java.util.EventObject;
  18.  
  19. public class BasicDesktopIconUI$MotionListener extends MouseAdapter implements MouseMotionListener, Serializable {
  20.    // $FF: synthetic field
  21.    BasicDesktopIconUI this$0;
  22.    // $FF: renamed from: _x int
  23.    int field_0;
  24.    // $FF: renamed from: _y int
  25.    int field_1;
  26.    int __x;
  27.    int __y;
  28.    Rectangle startingBounds;
  29.  
  30.    public void mouseReleased(MouseEvent e) {
  31.       this.field_0 = 0;
  32.       this.field_1 = 0;
  33.       this.__x = 0;
  34.       this.__y = 0;
  35.       this.startingBounds = null;
  36.    }
  37.  
  38.    public void mousePressed(MouseEvent e) {
  39.       Point p = SwingUtilities.convertPoint((Component)((EventObject)e).getSource(), e.getX(), e.getY(), (Component)null);
  40.       this.__x = e.getX();
  41.       this.__y = e.getY();
  42.       this.field_0 = p.x;
  43.       this.field_1 = p.y;
  44.       this.startingBounds = this.this$0.desktopIcon.getBounds();
  45.  
  46.       try {
  47.          this.this$0.frame.setSelected(true);
  48.       } catch (PropertyVetoException var3) {
  49.       }
  50.  
  51.       if (this.this$0.desktopIcon.getParent() instanceof JLayeredPane) {
  52.          ((JLayeredPane)this.this$0.desktopIcon.getParent()).moveToFront(this.this$0.desktopIcon);
  53.       }
  54.  
  55.       if (e.getClickCount() > 1 && this.this$0.frame.isIconifiable() && this.this$0.frame.isIcon()) {
  56.          this.this$0.deiconize();
  57.       }
  58.  
  59.    }
  60.  
  61.    public void mouseMoved(MouseEvent e) {
  62.    }
  63.  
  64.    public void mouseDragged(MouseEvent e) {
  65.       Point p = SwingUtilities.convertPoint((Component)((EventObject)e).getSource(), e.getX(), e.getY(), (Component)null);
  66.       Insets i = this.this$0.desktopIcon.getInsets();
  67.       int pWidth = ((JComponent)this.this$0.desktopIcon.getParent()).getWidth();
  68.       int pHeight = ((JComponent)this.this$0.desktopIcon.getParent()).getHeight();
  69.       if (this.startingBounds != null) {
  70.          int newX = this.startingBounds.x - (this.field_0 - p.x);
  71.          int newY = this.startingBounds.y - (this.field_1 - p.y);
  72.          if (newX + i.left <= -this.__x) {
  73.             newX = -this.__x - i.left;
  74.          }
  75.  
  76.          if (newY + i.top <= -this.__y) {
  77.             newY = -this.__y - i.top;
  78.          }
  79.  
  80.          if (newX + this.__x + i.right > pWidth) {
  81.             newX = pWidth - this.__x - i.right;
  82.          }
  83.  
  84.          if (newY + this.__y + i.bottom > pHeight) {
  85.             newY = pHeight - this.__y - i.bottom;
  86.          }
  87.  
  88.          JDesktopPane d;
  89.          if ((d = this.this$0.desktopIcon.getDesktopPane()) != null) {
  90.             DesktopManager dm = d.getDesktopManager();
  91.             dm.setBoundsForFrame(this.this$0.desktopIcon, newX, newY, this.this$0.desktopIcon.getWidth(), this.this$0.desktopIcon.getHeight());
  92.          } else {
  93.             this.moveAndRepaint(this.this$0.desktopIcon, newX, newY, this.this$0.desktopIcon.getWidth(), this.this$0.desktopIcon.getHeight());
  94.          }
  95.  
  96.       }
  97.    }
  98.  
  99.    public void moveAndRepaint(JComponent f, int newX, int newY, int newWidth, int newHeight) {
  100.       Rectangle r = ((Component)f).getBounds();
  101.       ((Component)f).setBounds(newX, newY, newWidth, newHeight);
  102.       SwingUtilities.computeUnion(newX, newY, newWidth, newHeight, r);
  103.       ((Component)f).getParent().repaint(r.x, r.y, r.width, r.height);
  104.    }
  105.  
  106.    // $FF: synthetic method
  107.    public BasicDesktopIconUI$MotionListener(BasicDesktopIconUI this$0) {
  108.       this.this$0 = this$0;
  109.    }
  110. }
  111.